proc cmd {text c} {
	if {[string range [string tolower $text] 0 [expr [string length $c]-1]]=="$c"} {
		return 1
	} else {return 0}
}



#from tkabber
proc user_from_jid {jid} {
    set user $jid
    regexp {(.*@.*)/.*} $jid temp user

    return $user
}
#from tkabber
proc node_and_server_from_jid {jid} {
    set nas $jid
    regexp {([^/]*)/.*} $jid temp nas

    return $nas
}
#from tkabber
proc server_from_jid {jid} {
    set serv $jid
    regexp {([^/]*)/.*} $jid temp serv
    regexp {[^@]*@(.*)} $serv temp serv

    return $serv
}
#from tkabber
proc resource_from_jid {jid} {
    set resource ""
    regexp {[^/]*/(.*)} $jid temp resource

    return $resource
}
#from tkabber
proc node_from_jid {jid} {
    set node ""
    regexp {^([^@/]*)@.*} $jid temp node

    return $node
}

proc sendxml {xlib text} {
    set tmp [string map {& &amp; \" &quot; 
			\x00 " " \x01 " " \x02 " " \x03 " "
			\x04 " " \x05 " " \x06 " " \x07 " "
			\x08 " "                   \x0B " "
			\x0C " "          \x0E " " \x0F " "
			\x10 " " \x11 " " \x12 " " \x13 " "
			\x14 " " \x15 " " \x16 " " \x17 " "
			\x18 " " \x19 " " \x1A " " \x1B " "
			\x1C " " \x1D " " \x1E " " \x1F " "
		        \x7F " "} $text]
xmpp::outText $xlib $tmp
}
proc gm {xlib to body} {
	set t [node_and_server_from_jid $to]
	set to [resource_from_jid $to]
	::xmpp::sendMessage $xlib "$t" -type groupchat -body "$to: $body"
}
proc pm {xlib to body} {
::xmpp::sendMessage $xlib $to -type chat -body "$body"
}
proc qa {xlib from type body} {
::xmpp::sendMessage $xlib $from -type $type -body "$body"
}
